mirror of
https://github.com/actions/cache.git
synced 2024-11-14 01:51:46 +01:00
Added more assertions as values can't be checked
This commit is contained in:
parent
87a7d01109
commit
407044787b
1 changed files with 17 additions and 0 deletions
|
@ -30,12 +30,19 @@ test("StateProvider saves states", async () => {
|
||||||
.mockImplementation(name =>
|
.mockImplementation(name =>
|
||||||
jest.requireActual("@actions/core").getState(name)
|
jest.requireActual("@actions/core").getState(name)
|
||||||
);
|
);
|
||||||
|
|
||||||
const saveStateMock = jest
|
const saveStateMock = jest
|
||||||
.spyOn(core, "saveState")
|
.spyOn(core, "saveState")
|
||||||
.mockImplementation((key, value) => {
|
.mockImplementation((key, value) => {
|
||||||
return jest.requireActual("@actions/core").saveState(key, value);
|
return jest.requireActual("@actions/core").saveState(key, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const setOutputMock = jest
|
||||||
|
.spyOn(core, "setOutput")
|
||||||
|
.mockImplementation((key, value) => {
|
||||||
|
return jest.requireActual("@actions/core").setOutput(key, value);
|
||||||
|
});
|
||||||
|
|
||||||
const cacheMatchedKey = "node-cache";
|
const cacheMatchedKey = "node-cache";
|
||||||
|
|
||||||
const stateProvider: IStateProvider = new StateProvider();
|
const stateProvider: IStateProvider = new StateProvider();
|
||||||
|
@ -46,6 +53,7 @@ test("StateProvider saves states", async () => {
|
||||||
|
|
||||||
expect(getStateMock).toHaveBeenCalledTimes(2);
|
expect(getStateMock).toHaveBeenCalledTimes(2);
|
||||||
expect(saveStateMock).toHaveBeenCalledTimes(2);
|
expect(saveStateMock).toHaveBeenCalledTimes(2);
|
||||||
|
expect(setOutputMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("NullStateProvider saves outputs", async () => {
|
test("NullStateProvider saves outputs", async () => {
|
||||||
|
@ -54,11 +62,19 @@ test("NullStateProvider saves outputs", async () => {
|
||||||
.mockImplementation(name =>
|
.mockImplementation(name =>
|
||||||
jest.requireActual("@actions/core").getState(name)
|
jest.requireActual("@actions/core").getState(name)
|
||||||
);
|
);
|
||||||
|
|
||||||
const setOutputMock = jest
|
const setOutputMock = jest
|
||||||
.spyOn(core, "setOutput")
|
.spyOn(core, "setOutput")
|
||||||
.mockImplementation((key, value) => {
|
.mockImplementation((key, value) => {
|
||||||
return jest.requireActual("@actions/core").setOutput(key, value);
|
return jest.requireActual("@actions/core").setOutput(key, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const saveStateMock = jest
|
||||||
|
.spyOn(core, "saveState")
|
||||||
|
.mockImplementation((key, value) => {
|
||||||
|
return jest.requireActual("@actions/core").saveState(key, value);
|
||||||
|
});
|
||||||
|
|
||||||
const cacheMatchedKey = "node-cache";
|
const cacheMatchedKey = "node-cache";
|
||||||
const nullStateProvider: IStateProvider = new NullStateProvider();
|
const nullStateProvider: IStateProvider = new NullStateProvider();
|
||||||
nullStateProvider.setState(State.CacheMatchedKey, "outputValue");
|
nullStateProvider.setState(State.CacheMatchedKey, "outputValue");
|
||||||
|
@ -68,4 +84,5 @@ test("NullStateProvider saves outputs", async () => {
|
||||||
|
|
||||||
expect(getStateMock).toHaveBeenCalledTimes(0);
|
expect(getStateMock).toHaveBeenCalledTimes(0);
|
||||||
expect(setOutputMock).toHaveBeenCalledTimes(2);
|
expect(setOutputMock).toHaveBeenCalledTimes(2);
|
||||||
|
expect(saveStateMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue