Skip to content

Commit 71f16ed

Browse files
committed
Unit tests for new utility function
1 parent e8aeae6 commit 71f16ed

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/spec/utils_spec.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,56 @@ describe('Utils', function () {
232232
});
233233
});
234234

235+
describe('parseGPTSingleSizeArrayToRtbSize', function () {
236+
it('should return size string with input single size array', function () {
237+
var size = [300, 250];
238+
var output = utils.parseGPTSingleSizeArrayToRtbSize(size);
239+
assert.deepEqual(output, {w: 300, h: 250});
240+
});
241+
242+
it('should return size string with input single size array', function () {
243+
var size = ['300', '250'];
244+
var output = utils.parseGPTSingleSizeArrayToRtbSize(size);
245+
assert.deepEqual(output, {w: 300, h: 250});
246+
});
247+
248+
it('return undefined using string input', function () {
249+
var size = '1';
250+
var output = utils.parseGPTSingleSizeArrayToRtbSize(size);
251+
assert.equal(output, undefined);
252+
});
253+
254+
it('return undefined using number input', function () {
255+
var size = 1;
256+
var output = utils.parseGPTSingleSizeArrayToRtbSize(size);
257+
assert.equal(output, undefined);
258+
});
259+
260+
it('return undefined using one length single array', function () {
261+
var size = [300];
262+
var output = utils.parseGPTSingleSizeArrayToRtbSize(size);
263+
assert.equal(output, undefined);
264+
});
265+
266+
it('return undefined if the input is empty', function () {
267+
var size = '';
268+
var output = utils.parseGPTSingleSizeArrayToRtbSize(size);
269+
assert.equal(output, undefined);
270+
});
271+
272+
it('return undefined if the input is not a number', function () {
273+
var size = ['foo', 'bar'];
274+
var output = utils.parseGPTSingleSizeArrayToRtbSize(size);
275+
assert.equal(output, undefined);
276+
});
277+
278+
it('return undefined if the input is not a number 2', function () {
279+
var size = [300, 'foo'];
280+
var output = utils.parseGPTSingleSizeArrayToRtbSize(size);
281+
assert.equal(output, undefined);
282+
});
283+
});
284+
235285
describe('isA', function () {
236286
it('should return true with string object', function () {
237287
var output = utils.isA(obj_string, type_string);

0 commit comments

Comments
 (0)