Skip to content

Commit

Permalink
Tests: Improved tests by exposing repeating code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Jan 28, 2015
1 parent cd264fe commit 3d3fc8a
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 190 deletions.
69 changes: 69 additions & 0 deletions tests/plugins/notification/manual/_helpers/manualplayground.js
@@ -0,0 +1,69 @@
/* global editor, console */
/* exported manualPlayground */

'use strict';

var manualPlayground = {
init: function() {
editor.on( 'notificationShow', function( evt ) {
console.log( evt );
} );
editor.on( 'notificationUpdate', function( evt ) {
console.log( evt );
} );
editor.on( 'notificationHide', function( evt ) {
console.log( evt );
} );
},

emulateProgress: function() {
var notification = editor.showNotification( 'Uploading image.png', 'progress', 0 ),
scenario = [
{ progress: 0.05, message: 'Uploading image.png 5%...' },
{ progress: 0.1, message: 'Uploading image.png 10%...' },
{ progress: 0.15, message: 'Uploading image.png 15%...' },
{ progress: 0.2, message: 'Uploading image.png 20%...' },
{ progress: 0.25, message: 'Uploading image.png 25%...' },
{ progress: 0.3, message: 'Uploading image.png 30%...' },
{ progress: 0.35, message: 'Uploading image.png 35%...' },
{ progress: 0.4, message: 'Uploading image.png 40%...' },
{ progress: 0.45, message: 'Uploading image.png 45%...' },
{ progress: 0.5, message: 'Uploading image.png 50%...' },
{ progress: 0.55, message: 'Uploading image.png 55%...' },
{ progress: 0.6, message: 'Uploading image.png 60%...' },
{ progress: 0.65, message: 'Uploading image.png 65%...' },
{ progress: 0.7, message: 'Uploading image.png 70%...' },
{ progress: 0.75, message: 'Uploading image.png 75%...' },
{ progress: 0.8, message: 'Uploading image.png 80%...' },
{ progress: 0.85, message: 'Uploading image.png 85%...' },
{ progress: 0.9, message: 'Uploading image.png 90%...' },
{ progress: 0.95, message: 'Uploading image.png 95%...' },
{ type: 'success', message: 'File image.png uploaded.', important: true }
];

var interval = setInterval( function() {
if ( !scenario.length ) {
clearInterval( interval );
} else {
notification.update( scenario.shift() );
}
}, 300 );

editor.focus();
},

showWarning: function() {
editor.showNotification( 'Vitae risus eget ante <a href="http://test/">mau</a> convallis.', 'warning' );
editor.focus();
},

showSuccess: function() {
editor.showNotification( 'Success!', 'success' );
editor.focus();
},

showInfo: function() {
editor.showNotification( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae risus eget ante mae convallis.', 'info' );
editor.focus();
}
};
71 changes: 8 additions & 63 deletions tests/plugins/notification/manual/classic.html
Expand Up @@ -2,75 +2,20 @@
<textarea cols="80" id="editor1" name="editor1" rows="10">
&lt;p&gt;&lt;strong&gt;Apollo 11&lt;/strong&gt; was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.&lt;/p&gt;&lt;p&gt;Armstrong spent about three and a half two and a half hours outside the spacecraft, Aldrin slightly less; and together they collected 47.5 pounds (21.5&nbsp;kg) of lunar material for return to Earth. A third member of the mission, Michael Collins, piloted the command spacecraft alone in lunar orbit until Armstrong and Aldrin returned to it for the trip back to Earth.&lt;/p&gt;&lt;p&gt;Broadcasting and &lt;em&gt;quotes&lt;/em&gt; &lt;/p&gt;&lt;p&gt;Broadcast on live TV to a world-wide audience, Armstrong stepped onto the lunar surface and described the event as:&lt;/p&gt;&lt;p&gt;One small step for [a] man, one giant leap for mankind.&lt;/p&gt;&lt;p&gt;Apollo 11 effectively ended the Space Race and fulfilled a national goal proposed in 1961 by the late U.S. President John F. Kennedy in a speech before the United States Congress:&lt;/p&gt;&lt;p&gt;[...] before this decade is out, of landing a man on the Moon and returning him safely to the Earth.&lt;/p&gt;&lt;p&gt;Technical details &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Mission crew&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;PositionAstronaut&lt;/p&gt;&lt;p&gt;CommanderNeil A. Armstrong&lt;/p&gt;&lt;p&gt;Command Module PilotMichael Collins&lt;/p&gt;&lt;p&gt;Lunar Module PilotEdwin "Buzz" E. Aldrin, Jr.&lt;/p&gt;&lt;p&gt;Launched by a &lt;strong&gt;Saturn V&lt;/strong&gt; rocket from Kennedy Space Center in Merritt Island, Florida on July 16, Apollo 11 was the fifth manned mission of NASA's Apollo program. The Apollo spacecraft had three parts:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Command Module&lt;/strong&gt; with a cabin for the three astronauts which was the only part which landed back on Earth&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Service Module&lt;/strong&gt; which supported the Command Module with propulsion, electrical power, oxygen and water&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Lunar Module&lt;/strong&gt; for landing on the Moon.&lt;/p&gt;&lt;p&gt;After being sent to the Moon by the Saturn V's upper stage, the astronauts separated the spacecraft from it and travelled for three days until they entered into lunar orbit. Armstrong and Aldrin then moved into the Lunar Module and landed in the Sea of Tranquility. They stayed a total of about 21 and a half hours on the lunar surface. After lifting off in the upper part of the Lunar Module and rejoining Collins in the Command Module, they returned to Earth and landed in the Pacific Ocean on July 24.&lt;/p&gt;&lt;p&gt;Source: Wikipedia.org&lt;/p&gt;
</textarea>
<p style="width: 700px;">
<input onclick="manualPlayground.showWarning();" type="button" value="Show warning notification">
<input onclick="manualPlayground.showSuccess();" type="button" value="Show success notification">
<input onclick="manualPlayground.showInfo();" type="button" value="Show info notification">
<input onclick="manualPlayground.emulateProgress();" type="button" value="Show progress notification">
</p>
<script>
var editor = CKEDITOR.replace( 'editor1', {
extraPlugins: 'notification',
width: 650,
toolbar: [ [ 'Undo', 'Redo' ], [ 'Bold', 'Italic', 'Underline' ] ]
} );

function emulateProgress() {
var notification = editor.showNotification( 'Uploading image.png', 'progress', 0 ),
scenario = [
{ progress: 0.05, message: 'Uploading image.png 5%...' },
{ progress: 0.1, message: 'Uploading image.png 10%...' },
{ progress: 0.15, message: 'Uploading image.png 15%...' },
{ progress: 0.2, message: 'Uploading image.png 20%...' },
{ progress: 0.25, message: 'Uploading image.png 25%...' },
{ progress: 0.3, message: 'Uploading image.png 30%...' },
{ progress: 0.35, message: 'Uploading image.png 35%...' },
{ progress: 0.4, message: 'Uploading image.png 40%...' },
{ progress: 0.45, message: 'Uploading image.png 45%...' },
{ progress: 0.5, message: 'Uploading image.png 50%...' },
{ progress: 0.55, message: 'Uploading image.png 55%...' },
{ progress: 0.6, message: 'Uploading image.png 60%...' },
{ progress: 0.65, message: 'Uploading image.png 65%...' },
{ progress: 0.7, message: 'Uploading image.png 70%...' },
{ progress: 0.75, message: 'Uploading image.png 75%...' },
{ progress: 0.8, message: 'Uploading image.png 80%...' },
{ progress: 0.85, message: 'Uploading image.png 85%...' },
{ progress: 0.9, message: 'Uploading image.png 90%...' },
{ progress: 0.95, message: 'Uploading image.png 95%...' },
{ type: 'success', message: 'File image.png uploaded.', important: true }
];

var interval = setInterval( function() {
if( !scenario.length ) {
clearInterval( interval );
} else {
notification.update( scenario.shift() );
}
}, 300 );
}

function showWarning() {
editor.showNotification( 'Vitae risus eget ante <a href="http://test/">mau</a> convallis.', 'warning' );
}

function showSuccess() {
editor.showNotification( 'Success!', 'success' );
}

function showInfo() {
editor.showNotification( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae risus eget ante mae convallis.', 'info' );
}

editor.on( 'notificationShow', function( evt ) {
console.log( evt );
} );
editor.on( 'notificationUpdate', function( evt ) {
console.log( evt );
} );
editor.on( 'notificationHide', function( evt ) {
console.log( evt );
} );

window.scrollTo(2950, 2950);
manualPlayground.init();
window.scrollTo( 2950, 2950 );
</script>
<p style="width:700px;">
<input onclick="showWarning();" type="button" value="Show warning notification">
<input onclick="showSuccess();" type="button" value="Show success notification">
<input onclick="showInfo();" type="button" value="Show info notification">
<input onclick="emulateProgress();" type="button" value="Show progress notification">
</p>
</div>
1 change: 1 addition & 0 deletions tests/plugins/notification/manual/classic.md
@@ -1,5 +1,6 @@
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, basicstyles, notification
@bender-include: _helpers/manualplayground.js

* If you don't see the editor, scroll the page to the center.
* Play with notification using buttons.
Expand Down
71 changes: 8 additions & 63 deletions tests/plugins/notification/manual/inline.html
Expand Up @@ -20,6 +20,12 @@
<p>After being sent to the Moon by the Saturn V's upper stage, the astronauts separated the spacecraft from it and travelled for three days until they entered into lunar orbit. Armstrong and Aldrin then moved into the Lunar Module and landed in the Sea of Tranquility. They stayed a total of about 21 and a half hours on the lunar surface. After lifting off in the upper part of the Lunar Module and rejoining Collins in the Command Module, they returned to Earth and landed in the Pacific Ocean on July 24.</p>
<p>Source: Wikipedia.org</p>
</div>
<p style="width:700px;">
<input onclick="manualPlayground.showWarning();" type="button" value="Show warning notification">
<input onclick="manualPlayground.showSuccess();" type="button" value="Show success notification">
<input onclick="manualPlayground.showInfo();" type="button" value="Show info notification">
<input onclick="manualPlayground.emulateProgress();" type="button" value="Show progress notification">
</p>
<script>
CKEDITOR.disableAutoInline = true;

Expand All @@ -28,69 +34,8 @@
toolbar: [ [ 'Undo', 'Redo' ], [ 'Bold', 'Italic', 'Underline' ] ]
} );

function emulateProgress() {
var notification = editor.showNotification( 'Uploading image.png', 'progress', 0 ),
scenario = [
{ progress: 0.05, message: 'Uploading image.png 5%...' },
{ progress: 0.1, message: 'Uploading image.png 10%...' },
{ progress: 0.15, message: 'Uploading image.png 15%...' },
{ progress: 0.2, message: 'Uploading image.png 20%...' },
{ progress: 0.25, message: 'Uploading image.png 25%...' },
{ progress: 0.3, message: 'Uploading image.png 30%...' },
{ progress: 0.35, message: 'Uploading image.png 35%...' },
{ progress: 0.4, message: 'Uploading image.png 40%...' },
{ progress: 0.45, message: 'Uploading image.png 45%...' },
{ progress: 0.5, message: 'Uploading image.png 50%...' },
{ progress: 0.55, message: 'Uploading image.png 55%...' },
{ progress: 0.6, message: 'Uploading image.png 60%...' },
{ progress: 0.65, message: 'Uploading image.png 65%...' },
{ progress: 0.7, message: 'Uploading image.png 70%...' },
{ progress: 0.75, message: 'Uploading image.png 75%...' },
{ progress: 0.8, message: 'Uploading image.png 80%...' },
{ progress: 0.85, message: 'Uploading image.png 85%...' },
{ progress: 0.9, message: 'Uploading image.png 90%...' },
{ progress: 0.95, message: 'Uploading image.png 95%...' },
{ type: 'success', message: 'File image.png uploaded.', important: true }
];

var interval = setInterval( function() {
if( !scenario.length ) {
clearInterval( interval );
} else {
notification.update( scenario.shift() );
}
}, 300 );
}

function showWarning() {
editor.showNotification( 'Vitae risus eget ante <a href="http://test/">mau</a> convallis.', 'warning' );
}

function showSuccess() {
editor.showNotification( 'Success!', 'success' );
}

function showInfo() {
editor.showNotification( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae risus eget ante mae convallis.', 'info' );
}

editor.on( 'notificationShow', function( evt ) {
console.log( evt );
} );
editor.on( 'notificationUpdate', function( evt ) {
console.log( evt );
} );
editor.on( 'notificationHide', function( evt ) {
console.log( evt );
} );

window.scrollTo(2950, 2950);
manualPlayground.init();
window.scrollTo( 2950, 2950 );
</script>
<p style="width:700px;">
<input onclick="showWarning();" type="button" value="Show warning notification">
<input onclick="showSuccess();" type="button" value="Show success notification">
<input onclick="showInfo();" type="button" value="Show info notification">
<input onclick="emulateProgress();" type="button" value="Show progress notification">
</p>

</div>
1 change: 1 addition & 0 deletions tests/plugins/notification/manual/inline.md
@@ -1,5 +1,6 @@
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, basicstyles, notification, floatingspace
@bender-include: _helpers/manualplayground.js

* If you don't see the editor, scroll the page to the center.
* Play with notification using buttons.
Expand Down
72 changes: 8 additions & 64 deletions tests/plugins/notification/manual/inlinenarrow.html
Expand Up @@ -3,6 +3,12 @@
<p><strong>Apollo 11</strong></p>
<p>Spaceflight that landed the first humans on the Moon.</p>
</div>
<p style="width:700px;">
<input onclick="manualPlayground.showWarning();" type="button" value="Show warning notification">
<input onclick="manualPlayground.showSuccess();" type="button" value="Show success notification">
<input onclick="manualPlayground.showInfo();" type="button" value="Show info notification">
<input onclick="manualPlayground.emulateProgress();" type="button" value="Show progress notification">
</p>
<script>
CKEDITOR.disableAutoInline = true;

Expand All @@ -11,69 +17,7 @@
toolbar: [ [ 'Undo', 'Redo' ], [ 'Bold', 'Italic', 'Underline' ] ]
} );

function emulateProgress() {
var notification = editor.showNotification( 'Uploading image.png', 'progress', 0 ),
scenario = [
{ progress: 0.05, message: 'Uploading image.png 5%...' },
{ progress: 0.1, message: 'Uploading image.png 10%...' },
{ progress: 0.15, message: 'Uploading image.png 15%...' },
{ progress: 0.2, message: 'Uploading image.png 20%...' },
{ progress: 0.25, message: 'Uploading image.png 25%...' },
{ progress: 0.3, message: 'Uploading image.png 30%...' },
{ progress: 0.35, message: 'Uploading image.png 35%...' },
{ progress: 0.4, message: 'Uploading image.png 40%...' },
{ progress: 0.45, message: 'Uploading image.png 45%...' },
{ progress: 0.5, message: 'Uploading image.png 50%...' },
{ progress: 0.55, message: 'Uploading image.png 55%...' },
{ progress: 0.6, message: 'Uploading image.png 60%...' },
{ progress: 0.65, message: 'Uploading image.png 65%...' },
{ progress: 0.7, message: 'Uploading image.png 70%...' },
{ progress: 0.75, message: 'Uploading image.png 75%...' },
{ progress: 0.8, message: 'Uploading image.png 80%...' },
{ progress: 0.85, message: 'Uploading image.png 85%...' },
{ progress: 0.9, message: 'Uploading image.png 90%...' },
{ progress: 0.95, message: 'Uploading image.png 95%...' },
{ type: 'success', message: 'File image.png uploaded.', important: true }
];

var interval = setInterval( function() {
if( !scenario.length ) {
clearInterval( interval );
} else {
notification.update( scenario.shift() );
}
}, 300 );
}

function showWarning() {
editor.showNotification( 'Vitae risus eget ante <a href="http://test/">mau</a> convallis.', 'warning' );
}

function showSuccess() {
editor.showNotification( 'Success!', 'success' );
}

function showInfo() {
editor.showNotification( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae risus eget ante mae convallis.', 'info' );
}

editor.on( 'notificationShow', function( evt ) {
console.log( evt );
} );
editor.on( 'notificationUpdate', function( evt ) {
console.log( evt );
} );
editor.on( 'notificationHide', function( evt ) {
console.log( evt );
} );

window.scrollTo(2950, 2950);
manualPlayground.init();
window.scrollTo( 2950, 2950 );
</script>
<p style="width:700px;">
<input onclick="showWarning();" type="button" value="Show warning notification">
<input onclick="showSuccess();" type="button" value="Show success notification">
<input onclick="showInfo();" type="button" value="Show info notification">
<input onclick="emulateProgress();" type="button" value="Show progress notification">
</p>

</div>
1 change: 1 addition & 0 deletions tests/plugins/notification/manual/inlinenarrow.md
@@ -1,5 +1,6 @@
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, basicstyles, notification, floatingspace
@bender-include: _helpers/manualplayground.js

* If you don't see the editor, scroll the page to the center.
* Show notification using button.
Expand Down

0 comments on commit 3d3fc8a

Please sign in to comment.