Created
January 17, 2018 23:06
-
-
Save brunomacf/0a75a8c5ced63d7c07d8b79417feecdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Fake from "./component"; | |
import {shallow} from "enzyme"; | |
describe("Fake Component", () => { | |
describe("load method", () => { | |
describe("on valid url", () => { | |
it("should set remote object to component state", (done) => { | |
const url = "http:///....."; | |
const httpMock = { | |
request: jest.fn(() => ( | |
new Promise((resolve) => { | |
setTimeout(() => { | |
resolve({ | |
hello: "world" | |
}); | |
}, 1000); | |
}) | |
)) | |
}; | |
const wrapper = shallow( | |
<Fake | |
http={httpMock} | |
url={url} | |
/> | |
); | |
setTimeout(() => { | |
const data = Fake.state("data"); | |
expect(httpMock.request).toHavaBeenCalled(); | |
expect(data).toBeDefined(); | |
expect(typeof data).toBe("object"); | |
expect(data.hello).toBe("world"); | |
done(); | |
}, 1500); | |
}); | |
}); | |
describe("on invalid url", () => { | |
it("should print an error message inside component body"); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment