public-google-sheets-parser
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "public-google-sheets-parser", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Get JSONArray from public google sheets with using only spreadsheetId", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -15,3 +15,3 @@ # Public Google sheets parser | ||
There is a limitation that only the data of the first sheet can be imported, but it seems that it can be fully utilized for simple purposes, so I made it. | ||
**You can specify the sheet name to get a data. (Since v1.1.0)** | ||
@@ -18,0 +18,0 @@ It does not work in browsers where the [fetch API](https://caniuse.com/fetch) is not available. |
@@ -7,4 +7,2 @@ const test = require('tape') | ||
test('getSpreadsheetDataUsingFetch method should return expected result', async (t) => { | ||
t.plan(2) | ||
const resultWithoutSpreadsheetId = await parser.getSpreadsheetDataUsingFetch() | ||
@@ -24,4 +22,2 @@ t.equal(resultWithoutSpreadsheetId, null) | ||
test('filterUselessRows method should return expected array', (t) => { | ||
t.plan(1) | ||
const givenRows = [{ v: null }, { v: undefined }, { v: 0 }, { v: false }, { d: 2 }, null] | ||
@@ -37,4 +33,2 @@ | ||
test('applyHeaderIntoRows method should return expected array', (t) => { | ||
t.plan(1) | ||
const givenHeader = ['a', 'b', 'c'] | ||
@@ -55,4 +49,2 @@ const givenRows = [ | ||
test('parse method should return array even spreadsheetId is invalid', async (t) => { | ||
t.plan(2) | ||
const invalidSpreadsheetId = 'id_that_does_not_exist_anywhere' | ||
@@ -79,3 +71,3 @@ const resultWithInvalidSpreadsheetId = await parser.parse(invalidSpreadsheetId) | ||
test('should get 2nd sheet if specified', async (t) => { | ||
const spreadsheetId = '1wdU-Cf7Kn5ZvhcvRePOoL10urdTA6TWGndBSKDAiYbQ' | ||
const spreadsheetId = '10WDbAPAY7Xl5DT36VuMheTPTTpqx9x0C5sDCnh4BGps' | ||
const sheetName = 'Sheet2' | ||
@@ -87,1 +79,16 @@ const result = await parser.parse(spreadsheetId, sheetName) | ||
}) | ||
test('should parse properly after change sheetName on runtime', async (t) => { | ||
const spreadsheetId = '10WDbAPAY7Xl5DT36VuMheTPTTpqx9x0C5sDCnh4BGps' | ||
const firstSheetName = 'Sheet1' | ||
const secondSheetName = 'Sheet2' | ||
const firstResult = await parser.parse(spreadsheetId, firstSheetName) | ||
const firstExpected = [{ a: 1, b: 2, c: 3 }, { a: 4, b: 5, c: 6 }, { a: 7, b: 8, c: 9 }] | ||
t.deepEqual(firstResult, firstExpected) | ||
const secondResult = await parser.parse(spreadsheetId, secondSheetName) | ||
const secondExpected = [{ a: 10, b: 20, c: 30 }, { a: 40, b: 50, c: 60 }, { a: 70, b: 80, c: 90 }] | ||
t.deepEqual(secondResult, secondExpected) | ||
t.end() | ||
}) |
821659
231