|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +describe('ステージ3(意図した通りに DOM 要素の構造を変更できるようになる)', function(){ |
| 4 | + describe('DOMインターフェース編', function() { |
| 5 | + it('1 番の要素から幽霊要素を除去する', function(){ |
| 6 | + |
| 7 | + // チュートリアル |
| 8 | + // |
| 9 | + // ここに以下のコードを記述してください。 |
| 10 | + // |
| 11 | + // var element = document.querySelector('#firebrick'); |
| 12 | + // var ghost = document.querySelector('.ghost'); |
| 13 | + // element.removeChild(ghost); |
| 14 | + |
| 15 | + |
| 16 | + var firebrick = document.getElementById('firebrick'); |
| 17 | + expect(firebrick.childNodes.length).to.equal(1); |
| 18 | + expect(firebrick).to.have.property('textContent', '1'); |
| 19 | + }); |
| 20 | + |
| 21 | + |
| 22 | + it('2 番の要素からインベーダー要素を除去する', function(){ |
| 23 | + |
| 24 | + // ここにコードを記述してください。 |
| 25 | + |
| 26 | + |
| 27 | + var darkorange = document.getElementById('chocolate'); |
| 28 | + expect(darkorange.childNodes.length).to.equal(1); |
| 29 | + expect(darkorange).to.have.property('textContent', '2'); |
| 30 | + }); |
| 31 | + |
| 32 | + |
| 33 | + it('3 番の要素の左右の幽霊要素をすべて除去する', function(){ |
| 34 | + |
| 35 | + // ここにコードを記述してください。 |
| 36 | + |
| 37 | + |
| 38 | + var darkorange = document.querySelector('.mediumseagreen'); |
| 39 | + expect(darkorange).to.have.property('textContent', '3\uD83C\uDF3F'); |
| 40 | + }); |
| 41 | + |
| 42 | + |
| 43 | + it('4 番の水色の要素の最後に要素を追加する', function(){ |
| 44 | + var elementToAdd = document.createElement('span'); |
| 45 | + elementToAdd.textContent = '\uD83D\uDC2C'; |
| 46 | + |
| 47 | + // 上の elementToAdd を追加するコードをここに記述してください。 |
| 48 | + |
| 49 | + |
| 50 | + var turquoise = document.querySelector('.turquoise'); |
| 51 | + expect(turquoise.childNodes.length).to.equal(2); |
| 52 | + expect(turquoise).to.have.deep.property('childNodes[0].textContent', '4'); |
| 53 | + expect(turquoise).to.have.deep.property('childNodes[1]').equal(elementToAdd); |
| 54 | + }); |
| 55 | + |
| 56 | + |
| 57 | + it('5 番の青色の要素の最初に要素を追加する', function(){ |
| 58 | + var elementToAdd = document.createElement('span'); |
| 59 | + elementToAdd.textContent = '\uD83D\uDC1F'; |
| 60 | + |
| 61 | + // 上の elementToAdd を追加するコードをここに記述してください。 |
| 62 | + |
| 63 | + |
| 64 | + var blockquote = document.querySelector('blockquote'); |
| 65 | + expect(blockquote.childNodes.length).to.equal(2); |
| 66 | + expect(blockquote).to.have.deep.property('childNodes[0]').equal(elementToAdd); |
| 67 | + expect(blockquote).to.have.deep.property('childNodes[1].textContent', '5'); |
| 68 | + }); |
| 69 | + }); |
| 70 | + |
| 71 | + |
| 72 | + describe('jQuery 編', function() { |
| 73 | + it('6 番の要素から幽霊要素を除去する', function(){ |
| 74 | + |
| 75 | + // チュートリアル |
| 76 | + // |
| 77 | + // ここに以下のコードを記述してください。 |
| 78 | + // |
| 79 | + // $('.brown-ghost').remove(); |
| 80 | + |
| 81 | + |
| 82 | + var $brown = $('#brown'); |
| 83 | + expect($brown.children()).to.have.length(0); |
| 84 | + expect($brown).to.have.text('6'); |
| 85 | + }); |
| 86 | + |
| 87 | + |
| 88 | + it('7 番の要素からインベーダー要素を除去する', function(){ |
| 89 | + |
| 90 | + // ここにコードを記述してください。 |
| 91 | + |
| 92 | + |
| 93 | + // 参考情報 |
| 94 | + // http://api.jquery.com/category/manipulation/ |
| 95 | + |
| 96 | + var $darkorange = $('#darkorange'); |
| 97 | + expect($darkorange.children()).to.have.length(0); |
| 98 | + expect($darkorange).to.have.text('7'); |
| 99 | + }); |
| 100 | + |
| 101 | + |
| 102 | + it('8 番の要素の左右の幽霊要素をすべて除去する', function(){ |
| 103 | + |
| 104 | + // ここにコードを記述してください。 |
| 105 | + |
| 106 | + |
| 107 | + var $limegreen = $('.limegreen'); |
| 108 | + expect($limegreen).to.have.text('8\uD83C\uDF3F'); |
| 109 | + }); |
| 110 | + |
| 111 | + |
| 112 | + it('9 番の水色の要素の最後に要素を追加する', function(){ |
| 113 | + var $elementToAdd = $('<span>\uD83D\uDC2C</span>'); |
| 114 | + |
| 115 | + // 上の $elementToAdd を追加するコードをここに記述してください。 |
| 116 | + |
| 117 | + |
| 118 | + var $mediumturquoise = $('.mediumturquoise'); |
| 119 | + expect($mediumturquoise.children()).to.have.length(1); |
| 120 | + expect($mediumturquoise).to.have.text('9\uD83D\uDC2C'); |
| 121 | + }); |
| 122 | + |
| 123 | + |
| 124 | + it('10 番の青色の要素の最初に要素を追加する', function(){ |
| 125 | + var $elementToAdd = $('<span>\uD83D\uDC1F</span>'); |
| 126 | + |
| 127 | + // 上の $elementToAdd を追加するコードをここに記述してください。 |
| 128 | + |
| 129 | + |
| 130 | + var $p = $('p'); |
| 131 | + expect($p.children()).to.have.length(1); |
| 132 | + expect($p).to.have.text('\uD83D\uDC1F10'); |
| 133 | + }); |
| 134 | + }); |
| 135 | +}); |
0 commit comments