Files
smart-city-digital-twin-mar…/smart-app-city/frontend/node_modules/readline/test/test_readline.js
Eric FELIXINE e30ae8ed09 feat(smart-app): implement complete mobile app MVP
- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
2026-06-01 18:00:35 -04:00

138 lines
3.1 KiB
JavaScript

var fs = require('fs');
var readLine = require('../readline.js');
var test = require("tap").test;
test("test reading lines",function(t){
console.error("reading large file line by line asserts may take a while");
var rl = readLine('./fixtures/afile.txt');
rl.on("line", function (line,linecount){
t.ok(null !== line && undefined !== line);
});
rl.on("end",function (){
t.end();
});
});
test("numbers", function (t){
var rl = readLine('./fixtures/nmbr.txt');
var answer = 28;
var i=0;
rl.on("line", function (line){
var num = Number(line);
console.error(num);
i+=num;
});
rl.on("end", function (){
console.error(i,answer);
t.ok(answer === i, "answered");
t.end();
});
});
test("errors", function (t){
var rl = readLine("./Idontexist");
rl.on('error', function (e){
t.ok(e);
t.end();
});
rl.on('end', function (){
t.end();
});
rl.on('close', function(){
t.end();
});
});
test("line count", function(t){
var rl = readLine('./fixtures/nmbr.txt');
var expect = 7;
var actual = 0;
rl.on("line", function (line, ln){
console.log("line",line,ln);
actual=ln;
});
rl.on("end", function (){
t.ok(actual === expect,"line count is correct");
t.end();
});
});
test("byte count after first line", function(t){
var rl = readLine('./fixtures/nmbr.txt');
var actual = 0;
var expect;
rl.on("line", function (line, ln, byteCount){
if (expect === undefined) {
expect = line.length;
console.log("byte count",byteCount);
actual=byteCount;
t.ok(actual === expect,"byte count is correct");
t.end();
}
});
});
test("byte count", function(t){
var rl = readLine('./fixtures/nmbr.txt');
var expect = fs.statSync('./fixtures/nmbr.txt').size;
var actual = 0;
rl.on("line", function (line, ln, byteCount){
console.log("byte count",byteCount);
actual=byteCount;
});
rl.on("end", function (){
t.ok(actual === expect,"byte count is correct");
t.end();
});
});
test("processing error passed on", function(t){
var rl = readLine('./fixtures/nmbr.txt');
var lastError;
var lineCalls = 0;
rl.on("line", function (line, ln, byteCount){
lineCalls++;
if (ln === 7) {
throw new Error('fake error');
}
});
rl.on("error", function (err){
if (!lastError) {
lastError = err;
}
});
rl.on("end", function (){
t.ok(lastError.message === 'fake error','error is passed on');
t.ok(lineCalls === 7, 'line count ok');
t.end();
});
});
test("test ascii file reading",function(t){
var iconv = require('iconv-lite');
var testFileValidationKeywords = {
1: 'папка',
3: 'телефон',
11: 'электричество',
14: 'дерево'
};
var rl = readLine('./fixtures/file-in-win1251.txt', {
retainBuffer: true
});
rl.on("line", function (data,linecount){
var line = iconv.decode(data, 'win1251');
t.ok(!testFileValidationKeywords[linecount] || line.indexOf(testFileValidationKeywords[linecount]) > -1);
});
rl.on("end",function (){
t.end();
});
});