diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ab4ac57..7e9b3e6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -10,11 +10,11 @@ on: - feature/* env: - NODE_VERSION: 16.15 + NODE_VERSION: 18 jobs: build: - name: Lint Code Base + name: Test Code Base runs-on: ubuntu-latest steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index a9232c4..fdef5b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ by [**SWR Audio Lab**](https://lab.swr.de/) ## Changelog +- 2022-07-27 - v1.0.0 + - chore: move node-crc to swrlab account + - feat: add mocha tests for strings utils + - 2022-07-26 - v1.0.10-beta - chore: merge `frytg/undici-wrapper` into this package diff --git a/README.md b/README.md index c06044c..ae078c7 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ This repository contains several frequently used packages and scripts for easier access and maintenance. -*Please note: This project is still under development!* - - [SWR Audio Lab / Node.js Utils](#swr-audio-lab--nodejs-utils) - [Install](#install) - [Packages](#packages) diff --git a/package.json b/package.json index fd05a1e..acb5d01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@swrlab/utils", - "version": "1.0.10-beta", + "version": "1.0.0", "description": "Wrapping common SWR Audio Lab utils", "main": "./src/index.js", "engines": { @@ -24,9 +24,9 @@ "dependencies": { "@google-cloud/storage": "^6.2.3", "abort-controller": "^3.0.0", - "aws-sdk": "^2.1181.0", + "aws-sdk": "^2.1182.0", "chai": "^4.3.6", - "node-crc": "rafaelmaeuer/node-crc#v2.0.15", + "node-crc": "swrlab/node-crc#v2.0.15", "undici": "^5.8.0", "uuid": "8.3.2" }, diff --git a/test/test.js b/test/test.js index 8c4b953..0d994ad 100644 --- a/test/test.js +++ b/test/test.js @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ /* by SWR audio lab @@ -11,9 +12,150 @@ const { expect } = require('chai') const createHashedId = require('../utils/ard/createHashedId') +const strings = require('../packages/strings') -describe('Test ARD-CoreID', () => { - it('createHashedId test', () => { +describe('Test ARD-CoreID Hash', () => { + it('createHashedId("test") = 0c171b2e54a30c11', () => { expect(createHashedId('test')).to.equal('0c171b2e54a30c11') }) }) + +describe('Test getObjectLength', () => { + it('getObjectLength({ hello: "world" }) = 1', () => { + expect(strings.getObjectLength({ hello: 'world' })).to.equal(1) + }) + + it('getObjectLength({ hello: "world", foo: "bar" }) = 2', () => { + expect(strings.getObjectLength({ hello: 'world', foo: 'bar' })).to.equal(2) + }) +}) + +describe('Test isArray', () => { + it('isArray(["hello world"]) = true', () => { + expect(strings.isArray(['hello world'])).to.equal(true) + }) + + it('isArray({ hello: "world" }) = false', () => { + expect(strings.isArray({ hello: 'world' })).to.equal(false) + }) +}) + +describe('Test isEmptyArray', () => { + it('isEmptyArray([]) = true', () => { + expect(strings.isEmptyArray([])).to.equal(true) + }) + + it('isEmptyArray(["hello world"]) = false', () => { + expect(strings.isEmptyArray(['hello world'])).to.equal(false) + }) +}) + +describe('Test isEmptyObject', () => { + it('isEmptyObject({}) = true', () => { + expect(strings.isEmptyObject({})).to.equal(true) + }) + + it('isEmptyObject({ hello: "world" }) = false', () => { + expect(strings.isEmptyObject({ hello: 'world' })).to.equal(false) + }) +}) + +describe('Test isEven', () => { + it('isEven(2) = true', () => { + expect(strings.isEven(2)).to.equal(true) + }) + + it('isEven(1) = false', () => { + expect(strings.isEven(1)).to.equal(false) + }) +}) + +describe('Test isIncluded', () => { + it('isIncluded("hello world", "hello") = true', () => { + expect(strings.isIncluded('hello world', 'hello')).to.equal(true) + }) + + it('isIncluded("hello world", "earth") = false', () => { + expect(strings.isIncluded('hello world', 'earth')).to.equal(false) + }) +}) + +describe('Test isNull', () => { + it('isNull(null) = true', () => { + expect(strings.isNull(null)).to.equal(true) + }) + + it('isNull(undefined) = false', () => { + expect(strings.isNull(undefined)).to.equal(false) + }) +}) + +describe('Test isObject', () => { + it('isObject({ hello: "world" }) = true', () => { + expect(strings.isObject({ hello: 'world' })).to.equal(true) + }) + + it('isObject("hello world") = false', () => { + expect(strings.isObject('hello world')).to.equal(false) + }) +}) + +describe('Test isUndefined', () => { + it('isUndefined(undefined) = true', () => { + expect(strings.isUndefined(undefined)).to.equal(true) + }) + + it('isUndefined(null) = false', () => { + expect(strings.isUndefined(null)).to.equal(false) + }) +}) + +describe('Test notEmptyArray', () => { + it('notEmptyArray(["hello world"]) = true', () => { + expect(strings.notEmptyArray(['hello world'])).to.equal(true) + }) + + it('notEmptyArray([]) = false', () => { + expect(strings.notEmptyArray([])).to.equal(false) + }) +}) + +describe('Test notEmptyObject', () => { + it('notEmptyObject({ hello: "world" }) = true', () => { + expect(strings.notEmptyObject({ hello: 'world' })).to.equal(true) + }) + + it('notEmptyObject({}) = false', () => { + expect(strings.notEmptyObject({})).to.equal(false) + }) +}) + +describe('Test notNullOrUndefined', () => { + it('notNullOrUndefined("hello world") = true', () => { + expect(strings.notNullOrUndefined('hello world')).to.equal(true) + }) + + it('notNullOrUndefined(null) = false', () => { + expect(strings.notNullOrUndefined(null)).to.equal(false) + }) + + it('notNullOrUndefined(undefined) = false', () => { + expect(strings.notNullOrUndefined(undefined)).to.equal(false) + }) +}) + +describe('Test removeDoubleSpaces', () => { + it('removeDoubleSpaces("hello world")) = hello world', () => { + expect(strings.removeDoubleSpaces('hello world')).to.equal('hello world') + }) + + it('removeDoubleSpaces("hello world once again")) = hello world once again', () => { + expect(strings.removeDoubleSpaces('hello world once again')).to.equal('hello world once again') + }) +}) + +describe('Test toHex', () => { + it('toHex("hello world")) = 68656c6c6f20776f726c64', () => { + expect(strings.toHex('hello world')).to.equal('68656c6c6f20776f726c64') + }) +}) diff --git a/yarn.lock b/yarn.lock index bdb2c38..c90d8ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -461,10 +461,10 @@ available-typed-arrays@^1.0.5: resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== -aws-sdk@^2.1181.0: - version "2.1181.0" - resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1181.0.tgz#6ec2997881ae3df76e56d7150fc2992f12ce43dc" - integrity sha512-AAHSknRFAIjXBA/XNAL7gS79agr1LbS0oGimOJqJauGSJfWNaOpDc7z6OLNUQqGa5Joc3maD5QJcSKp1Pm/deQ== +aws-sdk@^2.1182.0: + version "2.1182.0" + resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1182.0.tgz#7364e3e104f62b61018a00f19f2ffc989b1780ed" + integrity sha512-iemVvLTc2iy0rz3xTp8zc/kD27gIfDF/mk6bxY8/35xMulKCVANWUkAH8jWRKReHh5F/gX4bp33dnfG63ny1Ww== dependencies: buffer "4.9.2" events "1.1.1" @@ -1965,9 +1965,9 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= -node-crc@rafaelmaeuer/node-crc#v2.0.15: +node-crc@swrlab/node-crc#v2.0.15: version "2.0.15" - resolved "https://codeload.github.com/rafaelmaeuer/node-crc/tar.gz/9d0d20f171efb60265bbc91246a2497856f5fd89" + resolved "https://codeload.github.com/swrlab/node-crc/tar.gz/9d0d20f171efb60265bbc91246a2497856f5fd89" dependencies: "@types/node" "^18.0.0" detect-libc "^2.0.1"