diff --git a/src/Story.js b/src/Story.js index f1d8185e..e214766b 100644 --- a/src/Story.js +++ b/src/Story.js @@ -74,7 +74,7 @@ class Story { * Creates a story. * @param {string} name - Name of the story. */ - constructor (name = '') { + constructor (name = 'Untitled Story') { // Every story has a name. this.name = name; // Store the creator. @@ -297,7 +297,7 @@ class Story { // If it does, we ignore it and return. if (this.getPassageByName(p.name) !== null) { // Warn user - console.warn('Ignored passage with same name as existing one!'); + console.warn('Warning: Ignored passage with same name as existing one!'); // return; } diff --git a/test/JSON/JSON.Parse.test.js b/test/JSON/JSON.Parse.test.js index 7eeef5f3..cb2307c3 100644 --- a/test/JSON/JSON.Parse.test.js +++ b/test/JSON/JSON.Parse.test.js @@ -16,7 +16,7 @@ describe('JSON', () => { const s = parseJSON(r.toJSON()); // Check all properties. - expect(s.name).toBe(''); + expect(s.name).toBe('Untitled Story'); expect(Object.keys(s.tagColors).length).toBe(0); expect(s.IFID).toBe(''); expect(s.start).toBe(''); @@ -52,7 +52,7 @@ describe('JSON', () => { it('Should parse everything but name', function () { const s = '{"tagColors":{"r":"red"},"ifid":"dd","start":"Start","formatVersion":"1.0","metadata":{"some":"thing"},"format":"Snowman","creator":"extwee","creatorVersion":"2.2.0","zoom":1,"passages":[{"name":"Start","tags":["tag1"],"metadata":{},"text":"Word"}]}'; const r = parseJSON(s); - expect(r.name).toBe(''); + expect(r.name).toBe('Untitled Story'); expect(Object.keys(r.tagColors).length).toBe(1); expect(r.IFID).toBe('DD'); expect(r.start).toBe('Start'); diff --git a/test/Story.test.js b/test/Story.test.js index 9da17d96..dab50d55 100644 --- a/test/Story.test.js +++ b/test/Story.test.js @@ -28,6 +28,11 @@ describe('Story', () => { s = new Story('Test'); expect(s.name).toBe('Test'); }); + + it('Should have default name', () => { + s = new Story(); + expect(s.name).toBe('Untitled Story'); + }); }); describe('creator', () => { @@ -401,7 +406,7 @@ describe('Story', () => { const s = new Story(); // Convert to string and then back to object. const result = JSON.parse(s.toJSON()); - expect(result.name).toBe(''); + expect(result.name).toBe('Untitled Story'); expect(Object.keys(result.tagColors).length).toBe(0); expect(result.ifid).toBe(''); expect(result.start).toBe(''); diff --git a/test/Twine2HTML/Twine2HTML.Parse.test.js b/test/Twine2HTML/Twine2HTML.Parse.test.js index 93e9beaa..6dfb22cc 100644 --- a/test/Twine2HTML/Twine2HTML.Parse.test.js +++ b/test/Twine2HTML/Twine2HTML.Parse.test.js @@ -37,7 +37,7 @@ describe('Twine2HTMLParser', () => { it('Should have default name', () => { const fr = readFileSync('test/Twine2HTML/Twine2HTMLParser/missingName.html', 'utf-8'); const story = parseTwine2HTML(fr); - expect(story.name).toBe(''); + expect(story.name).toBe('Untitled Story'); }); it('Should set a missing IFID to an empty string', () => {