Skip to content

Commit

Permalink
Extract strings tests into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Mar 23, 2021
1 parent 8a23242 commit f3c7d3f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
4 changes: 1 addition & 3 deletions es/utils/swagger.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* ISC License (ISC)
* Copyright (c) 2018 aeternity developers
* Copyright (c) 2021 aeternity developers
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand Down Expand Up @@ -526,7 +526,5 @@ export {
operation,
expandPath,
assertOne,
snakeToPascal,
pascalToSnake,
traverseKeys
}
37 changes: 37 additions & 0 deletions test/unit/string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* ISC License (ISC)
* Copyright (c) 2021 aeternity developers
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/

import '../'
import { describe, it } from 'mocha'
import { expect } from 'chai'
import { snakeToPascal, pascalToSnake } from '../../es/utils/string'

describe('Strings', function () {
describe('converts case', () => {
it('from snake to pascal', () => {
expect(snakeToPascal('foo_bar_baz')).to.equal('fooBarBaz')
expect(snakeToPascal('foo_bar_')).to.equal('fooBar_')
expect(snakeToPascal('_bar_baz')).to.equal('BarBaz')
})

it('from pascal to snake', () => {
expect(pascalToSnake('fooBarBaz')).to.equal('foo_bar_baz')
expect(pascalToSnake('fooBar')).to.equal('foo_bar')
expect(pascalToSnake('BarBaz')).to.equal('_bar_baz')
})
})
})
16 changes: 1 addition & 15 deletions test/unit/swagger.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* ISC License (ISC)
* Copyright (c) 2018 aeternity developers
* Copyright (c) 2021 aeternity developers
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand Down Expand Up @@ -47,20 +47,6 @@ describe('Swagger', function () {
})
})

describe('converts case', () => {
it('from snake to pascal', () => {
expect(internal.snakeToPascal('foo_bar_baz')).to.equal('fooBarBaz')
expect(internal.snakeToPascal('foo_bar_')).to.equal('fooBar_')
expect(internal.snakeToPascal('_bar_baz')).to.equal('BarBaz')
})

it('from pascal to snake', () => {
expect(internal.pascalToSnake('fooBarBaz')).to.equal('foo_bar_baz')
expect(internal.pascalToSnake('fooBar')).to.equal('foo_bar')
expect(internal.pascalToSnake('BarBaz')).to.equal('_bar_baz')
})
})

it('expands paths', () => {
assert.equal(internal.expandPath('/foo/{bar}/baz/{bop}', { bar: 1, bop: 2, useless: 3 }), '/foo/1/baz/2')
assert.equal(internal.expandPath('unchanged'), 'unchanged')
Expand Down

0 comments on commit f3c7d3f

Please sign in to comment.