Move tests to their own describe block (#3447)

This commit is contained in:
Shefali Joshi 2020-10-09 14:29:52 -07:00 committed by GitHub
parent f3d593bc1e
commit c756adad6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,11 +30,9 @@ describe("The Object API", () => {
beforeEach(() => { beforeEach(() => {
mockProvider = jasmine.createSpyObj("mock provider", [ mockProvider = jasmine.createSpyObj("mock provider", [
"create", "create",
"update", "update"
"get"
]); ]);
mockProvider.create.and.returnValue(Promise.resolve(true)); mockProvider.create.and.returnValue(Promise.resolve(true));
mockProvider.get.and.returnValue(Promise.resolve(mockDomainObject));
objectAPI.addProvider(TEST_NAMESPACE, mockProvider); objectAPI.addProvider(TEST_NAMESPACE, mockProvider);
}); });
it("Calls 'create' on provider if object is new", () => { it("Calls 'create' on provider if object is new", () => {
@ -59,6 +57,19 @@ describe("The Object API", () => {
expect(mockProvider.create).not.toHaveBeenCalled(); expect(mockProvider.create).not.toHaveBeenCalled();
expect(mockProvider.update).not.toHaveBeenCalled(); expect(mockProvider.update).not.toHaveBeenCalled();
}); });
});
});
describe("The get function", () => {
describe("when a provider is available", () => {
let mockProvider;
beforeEach(() => {
mockProvider = jasmine.createSpyObj("mock provider", [
"get"
]);
mockProvider.get.and.returnValue(Promise.resolve(mockDomainObject));
objectAPI.addProvider(TEST_NAMESPACE, mockProvider);
});
it("Caches multiple requests for the same object", () => { it("Caches multiple requests for the same object", () => {
expect(mockProvider.get.calls.count()).toBe(0); expect(mockProvider.get.calls.count()).toBe(0);