Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase smalltalk #3

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory" : "modules"
}
{
"directory" : "modules"
}
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -9,11 +9,11 @@
"key-spacing": "off"
},
"extends": [
"plugin:node/recommended",
"plugin:n/recommended",
"plugin:putout/recommended"
],
"plugins": [
"node",
"n",
"putout"
]
}
1 change: 0 additions & 1 deletion .madrun.mjs
Original file line number Diff line number Diff line change
@@ -26,4 +26,3 @@ export default {
function upload(name) {
return 'putasset -o coderaiser -r smalltalk -t v`version`' + ` -f ${name}`;
}

25 changes: 12 additions & 13 deletions .stylelintrc.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
extends: stylelint-config-standard
rules:
indentation: 4
declaration-block-trailing-semicolon: always
declaration-colon-space-before: null
selector-list-comma-newline-after: null
comment-empty-line-before: null
number-leading-zero: null
number-no-trailing-zeros: null
string-quotes: single
function-url-quotes: never
no-eol-whitespace: null
declaration-empty-line-before: null
max-empty-lines: 2

indentation: 4
declaration-block-trailing-semicolon: always
declaration-colon-space-before: null
selector-list-comma-newline-after: null
comment-empty-line-before: null
number-leading-zero: null
number-no-trailing-zeros: null
string-quotes: single
function-url-quotes: never
no-eol-whitespace: null
declaration-empty-line-before: null
max-empty-lines: 2
17 changes: 17 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
2023.12.03, v4.1.2

fix:
- 64f0fc8 export

feature:
- 13ca47e smalltalk: eslint-plugin-n v16.3.1
- d4c8994 smalltalk: postcss v8.4.32
- 6c4b74a drop coveralls
- 0e0345f smalltalk: nodemon v3.0.2
- cb46477 smalltalk: webpack-cli v5.1.4
- 924db6f smalltalk: eslint-plugin-putout v21.0.2
- acc397f smalltalk: putout v33.13.3
- f7041ab smalltalk: supertape v8.8.0
- 383d124 smalltalk: c8 v8.0.1
- 337c31a smalltalk: auto-globals v3.0.0

2022.07.13, v4.1.1

fix:
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@ const smalltalk = require('smalltalk/native');

When you need a bundled verseion use


```js
import smalltalk from 'smalltalk/bundle';
```
@@ -102,7 +101,8 @@ smalltalk
```js
const progress = smalltalk.progress('Cloud Commander', 'Copy /home/coderaiser -> /home/coderaiser/2');

progress.setProgress(41)
progress
.setProgress(41)
.catch(() => {
console.log('abort');
});
7 changes: 2 additions & 5 deletions css/smalltalk.css
Original file line number Diff line number Diff line change
@@ -7,13 +7,10 @@

transition: 200ms opacity;

bottom: 0;
left: 0;
inset: 0;
overflow: auto;
padding: 20px;
position: fixed;
right: 0;
top: 0;

z-index: 100;
}
@@ -33,7 +30,7 @@
z-index: 0;
}

@media only screen and (max-width: 500px) {
@media only screen and (width <= 500px) {
.smalltalk .page {
min-width: 0;
}
57 changes: 33 additions & 24 deletions lib/smalltalk.js
Original file line number Diff line number Diff line change
@@ -21,29 +21,28 @@ const BUTTON_OK_CANCEL = {

const zIndex = store(100);

exports.alert = (title, msg, options) => {
module.exports.alert = (title, msg, options) => {
const buttons = getButtons(options) || BUTTON_OK;
return showDialog(title, msg, '', buttons, options);
};

exports.prompt = (title, msg, value = '', options) => {
module.exports.prompt = (title, msg, value = '', options) => {
const type = getType(options);
const val = String(value)
.replace(/"/g, '&quot;');
const val = String(value).replace(/"/g, '&quot;');

const valueStr = `<input type="${ type }" value="${ val }" data-name="js-input">`;
const valueStr = `<input type="${type}" value="${val}" data-name="js-input">`;
const buttons = getButtons(options) || BUTTON_OK_CANCEL;

return showDialog(title, msg, valueStr, buttons, options);
};

exports.confirm = (title, msg, options) => {
module.exports.confirm = (title, msg, options) => {
const buttons = getButtons(options) || BUTTON_OK_CANCEL;

return showDialog(title, msg, '', buttons, options);
};

exports.progress = (title, message, options) => {
module.exports.progress = (title, message, options) => {
const valueStr = `
<progress value="0" data-name="js-progress" class="progress" max="100"></progress>
<span data-name="js-counter">0%</span>
@@ -106,8 +105,8 @@ function getTemplate(title, msg, value, buttons) {

return `<div class="page">
<div data-name="js-close" class="close-button"></div>
<header>${ title }</header>
<div class="content-area">${ encodedMsg }${ value }</div>
<header>${title}</header>
<div class="content-area">${encodedMsg}${value}</div>
<div class="action-area">
<div class="button-strip">
${parseButtons(buttons)}
@@ -170,6 +169,7 @@ function showDialog(title, msg, value, buttons, options) {
for (const event of ['click', 'contextmenu'])
dialog.addEventListener(event, (e) => {
e.stopPropagation();

for (const el of find(dialog, ['ok', 'input']))
el.focus();
});
@@ -184,21 +184,24 @@ function showDialog(title, msg, value, buttons, options) {

function keyDown_(dialog, ok, cancel, event) {
const KEY = {
ENTER : 13,
ESC : 27,
TAB : 9,
LEFT : 37,
UP : 38,
RIGHT : 39,
DOWN : 40,
ENTER: 13,
ESC: 27,
TAB: 9,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
};

const {keyCode} = event;
const el = event.target;

const namesAll = ['ok', 'cancel', 'input'];
const names = find(dialog, namesAll)
.map(getDataName);
const namesAll = [
'ok',
'cancel',
'input',
];
const names = find(dialog, namesAll).map(getDataName);

switch(keyCode) {
case KEY.ENTER:
@@ -220,9 +223,16 @@ function keyDown_(dialog, ok, cancel, event) {
break;

default:
['left', 'right', 'up', 'down'].filter((name) => keyCode === KEY[name.toUpperCase()]).forEach(() => {
changeButtonFocus(dialog, names);
});
[
'left',
'right',
'up',
'down',
]
.filter((name) => keyCode === KEY[name.toUpperCase()])
.forEach(() => {
changeButtonFocus(dialog, names);
});

break;
}
@@ -302,7 +312,7 @@ function closeDialog(el, dialog, ok, cancel) {
remove(dialog);
}

const query = currify((element, name) => element.querySelector(`[data-name="js-${ name }"]`));
const query = currify((element, name) => element.querySelector(`[data-name="js-${name}"]`));

function find(element, names) {
const elements = names
@@ -324,4 +334,3 @@ function remove(dialog) {
if (parentElement)
parentElement.removeChild(dialog);
}

7 changes: 3 additions & 4 deletions lib/smalltalk.native.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

require('../css/smalltalk.css');

exports.alert = (title, message) => {
module.exports.alert = (title, message) => {
const promise = new Promise((resolve) => {
alert(message);
resolve();
@@ -11,7 +11,7 @@ exports.alert = (title, message) => {
return promise;
};

exports.prompt = (title, message, value, options) => {
module.exports.prompt = (title, message, value, options) => {
const o = options;
const promise = new Promise((resolve, reject) => {
const noCancel = o && !o.cancel;
@@ -29,7 +29,7 @@ exports.prompt = (title, message, value, options) => {
return promise;
};

exports.confirm = (title, message, options) => {
module.exports.confirm = (title, message, options) => {
const o = options;
const noCancel = o && !o.cancel;
const promise = new Promise((resolve, reject) => {
@@ -46,4 +46,3 @@ exports.confirm = (title, message, options) => {

return promise;
};

23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "smalltalk",
"version": "4.1.1",
"version": "4.1.2",
"type": "commonjs",
"commitType": "colon",
"description": "Promise-based Alert, Confirm and Prompt replacement",
"homepage": "http://github.com/coderaiser/smalltalk",
"repository": {
@@ -11,7 +10,7 @@
},
"main": "lib/smalltalk.js",
"exports": {
".": "./lib/smalltalk",
".": "./lib/smalltalk.js",
"./bundle": "./dist/smalltalk.min.js"
},
"scripts": {
@@ -48,28 +47,28 @@
"url": "https://github.com/coderaiser/smalltalk/issues"
},
"devDependencies": {
"auto-globals": "^2.0.0",
"auto-globals": "^3.0.0",
"autoprefixer": "^10.0.1",
"c8": "^7.11.3",
"c8": "^8.0.1",
"clean-css-loader": "^4.1.1",
"coveralls": "^3.0.0",
"css-loader": "^6.7.1",
"css-modules-require-hook": "^4.2.3",
"eslint": "^8.19.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-putout": "^15.8.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-putout": "^21.0.2",
"madrun": "^9.0.5",
"nodemon": "^2.0.1",
"nodemon": "^3.0.2",
"postcss": "^8.4.32",
"putasset": "^6.0.0",
"putout": "^26.24.0",
"putout": "^33.13.3",
"style-loader": "^3.3.1",
"supertape": "^7.6.0",
"supertape": "^8.8.0",
"terser-webpack-plugin": "^5.0.0",
"try-to-tape": "^1.1.0",
"url-loader": "^4.0.0",
"version-io": "^4.0.1",
"webpack": "^5.1.3",
"webpack-cli": "^4.0.0",
"webpack-cli": "^5.1.4",
"wraptile": "^3.0.0"
},
"dependencies": {
153 changes: 85 additions & 68 deletions test/smalltalk.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
'use strict';

const path = require('path');
const {join} = require('node:path');
const process = require('node:process');
const fs = require('fs');

require('css-modules-require-hook/preset');

const autoGlobals = require('auto-globals');
const tape = require('supertape');
const stub = require('@cloudcmd/stub');
const currify = require('currify');
const wraptile = require('wraptile');

global.window = {};

const {UPDATE_FIXTURE} = process.env;

const smalltalk = require('../lib/smalltalk');
const {UPDATE_FIXTURE} = process.env;
const noop = () => {};
const isUpdateFixtures = UPDATE_FIXTURE === 'true' || UPDATE_FIXTURE === '1';
const {create} = autoGlobals;
const test = autoGlobals(tape);
const fixtureDir = path.join(__dirname, 'fixture');
const fixtureDir = join(__dirname, 'fixture');
const {stub} = tape;

const writeFixture = (name, data) => {
return fs.writeFileSync(`${fixtureDir}/${name}.html`, data);
};

const readFixture = (name) => {
const fn = () => fs.readFileSync(`${fixtureDir}/${name}.html`, 'utf8');

fn.update = !isUpdateFixtures ? noop : currify(writeFixture, name);

return fn;
@@ -88,16 +89,18 @@ test('smalltalk: alert: click', (t, {document}) => {
createElement.returns(el);
smalltalk.alert('title', 'message');

t.equal(ok.addEventListener.args.pop()[0], 'click', 'should set click listener');
const result = ok
.addEventListener
.args
.pop()[0];

t.equal(result, 'click', 'should set click listener');
t.end();
});

test('smalltalk: alert: close: remove', (t, {document}) => {
const parentElement = create();
const {
createElement,
querySelector,
} = document;
const {createElement, querySelector} = document;

const el = {
...create(),
@@ -125,15 +128,16 @@ test('smalltalk: alert: close: remove', (t, {document}) => {
target: ok,
});

t.equal(parentElement.removeChild.args.pop().pop(), el, 'should find smalltalk');
t.equal(parentElement
.removeChild
.args
.pop()
.pop(), el, 'should find smalltalk');
t.end();
});

test('smalltalk: alert: keydown: stopPropagation', (t, {document}) => {
const {
createElement,
querySelector,
} = document;
const {createElement, querySelector} = document;

const parentElement = create();

@@ -157,7 +161,11 @@ test('smalltalk: alert: keydown: stopPropagation', (t, {document}) => {

smalltalk.alert('title', 'message');

const [, keydown] = el.addEventListener.args.filter(([event]) => event === 'keydown').pop();
const [, keydown] = el
.addEventListener
.args
.filter(([event]) => event === 'keydown')
.pop();

const event = {
stopPropagation: stub(),
@@ -170,10 +178,7 @@ test('smalltalk: alert: keydown: stopPropagation', (t, {document}) => {
});

test('smalltalk: alert: click: stopPropagation: called', (t, {document}) => {
const {
createElement,
querySelector,
} = document;
const {createElement, querySelector} = document;

const parentElement = create();
const el = {
@@ -196,10 +201,14 @@ test('smalltalk: alert: click: stopPropagation: called', (t, {document}) => {

smalltalk.alert('title', 'message');

const [, click] = el.addEventListener.args.filter((a) => {
const [event] = a;
return event === 'click';
}).pop();
const [, click] = el
.addEventListener
.args
.filter((a) => {
const [event] = a;
return event === 'click';
})
.pop();

const event = {
stopPropagation: stub(),
@@ -243,7 +252,9 @@ test('smalltalk: alert: keydown: tab: preventDefault', (t, {document}) => {

smalltalk.alert('title', 'message');

const [, keydown] = el.addEventListener.args
const [, keydown] = el
.addEventListener
.args
.filter(([event]) => event === 'keydown')
.pop();

@@ -286,7 +297,9 @@ test('smalltalk: alert: keydown: tab: active name', (t, {document}) => {

smalltalk.alert('title', 'message');

const [, keydown] = el.addEventListener.args
const [, keydown] = el
.addEventListener
.args
.filter(([event]) => event === 'keydown')
.pop();

@@ -335,7 +348,9 @@ test('smalltalk: alert: keydown: left: focus', (t) => {

smalltalk.alert('title', 'message');

const [, keydown] = el.addEventListener.args
const [, keydown] = el
.addEventListener
.args
.filter(([event]) => event === 'keydown')
.pop();

@@ -355,10 +370,7 @@ test('smalltalk: alert: keydown: left: focus', (t) => {
});

test('smalltalk: alert: click: focus', (t, {document}) => {
const {
createElement,
querySelector,
} = document;
const {createElement, querySelector} = document;

const parentElement = create();
const el = {
@@ -381,7 +393,9 @@ test('smalltalk: alert: click: focus', (t, {document}) => {

smalltalk.alert('title', 'message');

const [, keydown] = el.addEventListener.args
const [, keydown] = el
.addEventListener
.args
.filter(([event]) => event === 'click')
.pop();

@@ -454,7 +468,8 @@ test('smalltalk: confirm: click on close', (t) => {
document.createElement.returns(el);
document.querySelector.returns(el);

smalltalk.confirm('title', 'message')
smalltalk
.confirm('title', 'message')
.catch((e) => {
t.ok(e, 'should reject');
t.end();
@@ -500,7 +515,9 @@ test('smalltalk: confirm: keydown: left: active name', (t, {document}) => {

smalltalk.confirm('title', 'message');

const [, keydown] = el.addEventListener.args
const [, keydown] = el
.addEventListener
.args
.filter(([event]) => event === 'keydown')
.pop();

@@ -559,7 +576,9 @@ test('smalltalk: confirm: keydown: left: active name: cancel', (t, {document}) =

smalltalk.confirm('title', 'message');

const [, keydown] = el.addEventListener.args
const [, keydown] = el
.addEventListener
.args
.filter(([event]) => event === 'keydown')
.pop();

@@ -580,10 +599,7 @@ test('smalltalk: confirm: keydown: left: active name: cancel', (t, {document}) =

test('smalltalk: confirm: keydown: esc: reject', (t, {document}) => {
const parentElement = create();
const {
createElement,
querySelector,
} = document;
const {createElement, querySelector} = document;

const el = {
...create(),
@@ -603,13 +619,16 @@ test('smalltalk: confirm: keydown: esc: reject', (t, {document}) => {
createElement.returns(el);
querySelector.returns(el);

smalltalk.confirm('title', 'message')
smalltalk
.confirm('title', 'message')
.catch((e) => {
t.ok(e, 'should reject');
t.end();
});

const [, keydown] = el.addEventListener.args
const [, keydown] = el
.addEventListener
.args
.filter(([event]) => event === 'keydown')
.pop();

@@ -627,10 +646,7 @@ test('smalltalk: confirm: keydown: esc: reject', (t, {document}) => {

test('smalltalk: confirm: keydown: enter', (t, {document}) => {
const parentElement = create();
const {
createElement,
querySelector,
} = document;
const {createElement, querySelector} = document;

const el = {
...create(),
@@ -650,13 +666,16 @@ test('smalltalk: confirm: keydown: enter', (t, {document}) => {
createElement.returns(el);
querySelector.returns(el);

smalltalk.confirm('title', 'message')
smalltalk
.confirm('title', 'message')
.then(() => {
t.pass('should resolve');
t.end();
});

const [, keydown] = el.addEventListener.args
const [, keydown] = el
.addEventListener
.args
.filter(([event]) => event === 'keydown')
.pop();

@@ -736,10 +755,7 @@ test('smalltalk: prompt: no value', (t, {document}) => {
});

test('smalltalk: prompt: click on ok', (t, {document}) => {
const {
createElement,
querySelector,
} = document;
const {createElement, querySelector} = document;

const dataName = (a) => `[data-name="js-${a}"]`;

@@ -769,7 +785,8 @@ test('smalltalk: prompt: click on ok', (t, {document}) => {
createElement.returns(el);
querySelector.returns(el);

smalltalk.prompt('title', 'message', value)
smalltalk
.prompt('title', 'message', value)
.then((result) => {
t.equal(result, value, 'should return value');
t.end();
@@ -784,12 +801,10 @@ test('smalltalk: prompt: click on ok', (t, {document}) => {

test('smalltalk: prompt: click on cancel', (t, {document}) => {
const dataName = (a) => `[data-name="js-${a}"]`;
const {
createElement,
querySelector,
} = document;
const {createElement, querySelector} = document;

const value = 'hello';

const input = {
...create(),
value,
@@ -815,7 +830,8 @@ test('smalltalk: prompt: click on cancel', (t, {document}) => {
createElement.returns(el);
querySelector.returns(el);

smalltalk.prompt('title', 'message', value)
smalltalk
.prompt('title', 'message', value)
.catch((e) => {
t.ok(e, 'should reject');
t.end();
@@ -830,12 +846,10 @@ test('smalltalk: prompt: click on cancel', (t, {document}) => {

test('smalltalk: prompt: click on cancel: cancel false', (t, {document}) => {
const dataName = (a) => `[data-name="js-${a}"]`;
const {
createElement,
querySelector,
} = document;
const {createElement, querySelector} = document;

const value = 'hello';

const input = {
...create(),
value,
@@ -864,7 +878,10 @@ test('smalltalk: prompt: click on cancel: cancel false', (t, {document}) => {
const fail = t.fail.bind(t);
const end = t.end.bind(t);

smalltalk.prompt('title', 'message', value, {cancel: false})
smalltalk
.prompt('title', 'message', value, {
cancel: false,
})
.then(wraptile(fail, 'should not pass'))
.catch(wraptile(fail, 'should not reject'))
.then(end);
@@ -881,12 +898,10 @@ test('smalltalk: prompt: click on cancel: cancel false', (t, {document}) => {

test('smalltalk: prompt: click on cancel: options: no cancel', (t, {document}) => {
const dataName = (a) => `[data-name="js-${a}"]`;
const {
createElement,
querySelector,
} = document;
const {createElement, querySelector} = document;

const value = 'hello';

const input = {
...create(),
value,
@@ -912,7 +927,8 @@ test('smalltalk: prompt: click on cancel: options: no cancel', (t, {document}) =
createElement.returns(el);
querySelector.returns(el);

smalltalk.prompt('title', 'message', value, {})
smalltalk
.prompt('title', 'message', value, {})
.catch((e) => {
t.ok(e, 'should reject');
t.end();
@@ -976,6 +992,7 @@ test('smalltalk: progress: setProgress', (t, {document}) => {

test('smalltalk: progress: setProgress: 100', (t, {document}) => {
const valueEl = create();

valueEl.parentElement = create();

document.querySelector.returns(valueEl);
@@ -996,6 +1013,7 @@ test('smalltalk: progress: setProgress: 100', (t, {document}) => {

test('smalltalk: progress: remove', (t, {document}) => {
const valueEl = create();

valueEl.parentElement = create();

document.querySelector.returns(valueEl);
@@ -1016,4 +1034,3 @@ test('smalltalk: progress: remove', (t, {document}) => {
t.calledWith(removeChild, [el], 'should call removeChild');
t.end();
});

88 changes: 53 additions & 35 deletions test/smalltalk.native.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use strict';

const {
test,
stub,
} = require('supertape');
require('css-modules-require-hook/preset');

const {test, stub} = require('supertape');
const smalltalk = require('../lib/smalltalk.native');

global.window = {};
@@ -19,6 +17,7 @@ test('smalltalk.native: Promise', (t) => {

test('smalltalk.native: alert', (t) => {
const alert = stub();

global.alert = alert;

smalltalk.alert('title', 'message');
@@ -30,20 +29,24 @@ test('smalltalk.native: alert', (t) => {
test('smalltalk.native: alert: result', (t) => {
global.alert = stub();

smalltalk.alert('title', 'message').then(() => {
t.pass('promise should have been resolved');
t.end();
})
smalltalk
.alert('title', 'message')
.then(() => {
t.pass('promise should have been resolved');
t.end();
})
.catch((e) => {
t.fail(`should not reject ${e.message}`);
});
});

test('smalltalk.native: confirm', (t) => {
const confirm = stub().returns(false);

global.confirm = confirm;

smalltalk.confirm('title', 'message')
smalltalk
.confirm('title', 'message')
.catch(() => {
t.calledWith(confirm, ['message'], 'confirm should have been called with message');
t.end();
@@ -53,10 +56,12 @@ test('smalltalk.native: confirm', (t) => {
test('smalltalk.native: confirm: result: ok', (t) => {
global.confirm = stub().returns(true);

smalltalk.confirm('title', 'message').then(() => {
t.pass('should resolve');
t.end();
})
smalltalk
.confirm('title', 'message')
.then(() => {
t.pass('should resolve');
t.end();
})
.catch((e) => {
t.notOk(e, 'should not reject');
});
@@ -65,10 +70,12 @@ test('smalltalk.native: confirm: result: ok', (t) => {
test('smalltalk.native: confirm: result: cancel', (t) => {
global.confirm = stub().returns(false);

smalltalk.confirm('title', 'message').then(() => {
t.fail('should not resolve');
t.end();
})
smalltalk
.confirm('title', 'message')
.then(() => {
t.fail('should not resolve');
t.end();
})
.catch((e) => {
t.ok(e, 'should reject');
});
@@ -79,10 +86,14 @@ test('smalltalk.native: confirm: options: cancel', (t) => {

const cancel = false;

smalltalk.confirm('title', 'message', {cancel}).then(() => {
t.fail('should not resolve');
t.end();
})
smalltalk
.confirm('title', 'message', {
cancel,
})
.then(() => {
t.fail('should not resolve');
t.end();
})
.catch(() => {
t.fail('should not reject');
});
@@ -92,6 +103,7 @@ test('smalltalk.native: confirm: options: cancel', (t) => {

test('smalltalk.native: prompt', (t) => {
const prompt = stub();

global.prompt = prompt;

smalltalk.prompt('title', 'message', 'value');
@@ -103,10 +115,12 @@ test('smalltalk.native: prompt', (t) => {
test('smalltalk.native: prompt: result: ok', (t) => {
global.prompt = stub().returns('hello');

smalltalk.prompt('title', 'message', 'value').then((value) => {
t.equal(value, 'hello', 'should resolve value');
t.end();
})
smalltalk
.prompt('title', 'message', 'value')
.then((value) => {
t.equal(value, 'hello', 'should resolve value');
t.end();
})
.catch((e) => {
t.fail(`should not reject ${e.message}`);
});
@@ -115,10 +129,12 @@ test('smalltalk.native: prompt: result: ok', (t) => {
test('smalltalk.native: prompt: result: cancel', (t) => {
global.prompt = stub().returns(null);

smalltalk.prompt('title', 'message', 'value').then(() => {
t.fail('should not resolve');
t.end();
})
smalltalk
.prompt('title', 'message', 'value')
.then(() => {
t.fail('should not resolve');
t.end();
})
.catch((e) => {
t.ok(e, 'should reject');
});
@@ -127,12 +143,14 @@ test('smalltalk.native: prompt: result: cancel', (t) => {
test('smalltalk.native: prompt: options: cancel', (t) => {
global.prompt = stub().returns(null);

smalltalk.prompt('title', 'message', 'value', {
cancel: false,
}).then(() => {
t.fail('should not resolve');
t.end();
})
smalltalk
.prompt('title', 'message', 'value', {
cancel: false,
})
.then(() => {
t.fail('should not resolve');
t.end();
})
.catch((e) => {
t.fail(`should not reject ${e.message}`);
});
6 changes: 5 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,11 @@ const devtool = 'source-map';

const rules = [{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'clean-css-loader'],
use: [
'style-loader',
'css-loader',
'clean-css-loader',
],
}, {
test: /\.(png|gif|svg|woff|woff2|eot|ttf)$/,
use: [{