diff --git a/jasmine_demo/index.js b/jasmine_demo/index.js index e9b8901..5c08601 100644 --- a/jasmine_demo/index.js +++ b/jasmine_demo/index.js @@ -7,4 +7,5 @@ const meinPlayer = new Player() meinPlayer.play(meinSong) if(meinPlayer.isPlaying){ console.log(meinPlayer.currentlyPlayingSong.title) -} \ No newline at end of file +} + diff --git a/jasmine_demo/lib/parse-to-proto.js b/jasmine_demo/lib/parse-to-proto.js new file mode 100644 index 0000000..ab3cd49 --- /dev/null +++ b/jasmine_demo/lib/parse-to-proto.js @@ -0,0 +1,7 @@ +function parseToProto(json, proto){ + return Object.assign(Object.create(proto), JSON.parse(json)) +} + + + +module.exports = { parseToProto} \ No newline at end of file diff --git a/jasmine_demo/spec/parse-to-proto-Specs.js b/jasmine_demo/spec/parse-to-proto-Specs.js new file mode 100644 index 0000000..0344c13 --- /dev/null +++ b/jasmine_demo/spec/parse-to-proto-Specs.js @@ -0,0 +1,15 @@ +describe("parseToProto", function() { + var obj; + + beforeEach(function() { + let proto = {category: "animal"} + }); + + it("should have category, type, name and age attribute", function() { + let obj = parseToProto('{"type": "cat", "name":"Mimi","age":3}', proto) + expect("animal").toEqual(obj.category); + expect("cat").toEqual(obj.type); + expect("Mimi").toEqual(obj.name); + expect(3).toEqual(obj.age); + }); +}); \ No newline at end of file