Files
smart-city-digital-twin-mar…/smart-app-city/frontend/node_modules/requireg/test/requiregSpec.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

154 lines
3.9 KiB
JavaScript

var path = require('path');
var expect = require('expect.js')
var resolvers = require('rewire')('../lib/resolvers')
require.cache[require.resolve('../lib/resolvers')] = { exports: resolvers }
var requiregModule = require('../lib/requireg')
var isWin32 = process.platform === 'win32'
var homeVar = isWin32 ? 'USERPROFILE' : 'HOME'
var homePath = process.env[homeVar]
describe('requireg', function () {
it('should be a function', function () {
expect(requiregModule).to.be.a('function')
})
describe('requireg API', function () {
it('should globalize', function () {
requiregModule.globalize()
expect(requireg).to.be.a('function')
})
})
describe('local modules', function () {
it('should resolve a local module', function () {
expect(requiregModule('expect.js')).to.be.equal(expect)
})
it('should throw an Error exception when no local module exists', function () {
expect(function () { requiregModule('nonexistent') }).to.throwError()
})
})
describe('global modules', function () {
describe('resolve only global', function () {
it('should not resolve a local module', function () {
expect(function () { requiregModule('expect.js', true) }).to.throwError()
})
})
describe('resolve via NODE_PATH', function () {
before(function () {
process.env.NODE_PATH = path.join(__dirname, 'fixtures', 'lib');
})
after(function () {
process.env.NODE_PATH = ''
})
it('should resolve the beaker package', function () {
expect(requiregModule('beaker')).to.be.true
})
it('should have the expected module path', function () {
expect(requiregModule.resolve('beaker'))
.to.be.equal(path.join(__dirname, 'fixtures', 'lib', 'node_modules', 'beaker', 'index.js'))
})
})
describe('resolve via $HOME', function () {
before(function () {
process.env[homeVar] = path.join(__dirname, 'fixtures', 'lib')
})
after(function () {
process.env[homeVar] = homePath
})
it('should resolve the beaker package', function () {
expect(requiregModule('beaker')).to.be.true
})
})
describe('resolve via $NODE_MODULES', function () {
before(function () {
process.env.NODE_MODULES = path.join(__dirname, 'fixtures', 'lib')
})
after(function () {
process.env.NODE_MODULES = ''
})
it('should resolve the beaker package', function () {
expect(requiregModule('beaker')).to.be.true
})
})
describe('resolve via node execution path', function () {
var execPath = process.execPath
var rc = require('rc')
before(function () {
process.execPath = path.join(__dirname, 'fixtures', (isWin32 ? 'lib' : 'bin'), 'node')
})
after(function () {
process.execPath = execPath
})
it('should resolve the beaker package', function () {
expect(requiregModule('beaker')).to.be.true
})
it('should have the expected module path', function () {
expect(requiregModule.resolve('beaker'))
.to.be.equal(path.join(__dirname, 'fixtures', 'lib', 'node_modules', 'beaker', 'index.js'))
})
})
describe('resolve via npm prefix', function () {
var rc = require('rc')
before(function () {
resolvers.__set__('rc', function () {
return {
prefix: path.join(__dirname, 'fixtures', (isWin32 ? 'lib' : ''))
}
})
})
after(function () {
resolvers.__set__('rc', rc)
})
it('should resolve the beaker package', function () {
expect(requiregModule('beaker')).to.be.true
})
it('should have the expected module path', function () {
expect(requiregModule.resolve('beaker'))
.to.be.equal(path.join(__dirname, 'fixtures', 'lib', 'node_modules', 'beaker', 'index.js'))
})
})
})
})